const showToast = (text, icon = 'none', duration = 1500) => {
    wx.showToast({
        title: text,
        icon: icon,
        duration: duration
    })
}

const showLoading = (title, mask = true) => {
    return new Promise((resolve, reject) => {
        wx.showLoading({
            title: title,
            mask: mask,
            success: () => {
                resolve();
            },
            fail: () => {
                reject();
            }
        })
    })
}

const showModal = (title, content, isCancel = true) => {
    return new Promise((resolve, reject) => {
        wx.showModal({
            title: title,
            content: content,
            showCancel: isCancel,
            success: res => {
                resolve(res);
            },
            fail: () => {
                reject();
            }	
        })
    })
}

module.exports = {
    showToast,
    showLoading,
    showModal
}